From 85779c898d9ba719c06c2c9ba1b698f6d5de0c8a Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 2 Oct 2002 15:23:24 +0000 Subject: [PATCH] More fixes from Alex for csv_util.c git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@108 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/csv_util.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index 207c74a14..86e0f7c84 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -44,8 +44,7 @@ csv_stringclean(const char *string, const char *chararray) { } /* p2 - end of the original string */ - p2 = tmp; - while (*p2) p2++; + p2 = tmp + strlen(tmp); cp = chararray; @@ -88,20 +87,16 @@ csv_stringtrim(const char *string, const char *enclosure) elen = strlen(enclosure); } - p2 = tmp; + p2 = tmp + strlen(tmp) - 1; p1 = tmp; - /* advance p2 to the end of the string, then back it off. */ - while ((*p2) && (p2++)) { } - p2--; - /* trim off trailing whitespace */ - while (isspace(*p2)) { + while ((p2 > p1) && isspace(*p2)) { p2--; } /* advance p1 past any leading whitespace */ - while (isspace(*p1)) { + while ((p1 < p2) && (isspace(*p1))) { p1++; } @@ -202,3 +197,4 @@ csv_lineparse(const char *stringstart, const char *delimited_by, return (tmp); } + -- 2.30.2